#ifndef STX_ALGORITHM_COPY_IF_HPP
#define STX_ALGORITHM_COPY_IF_HPP

#include <stx/algorithm/common.hpp>

namespace stx {

template<class InputIterator, class OutputIterator, class Predicate>
inline OutputIterator
copy_if(
    InputIterator first,
    InputIterator last,
    OutputIterator result,
    Predicate pred)
{
    for (; first != last; ++first) {
        if (pred(*first)) {
            *result = *first;
            ++result;
        }
    }
    return result;
}

} // namespace stx

#endif // STX_ALGORITHM_COPY_IF_HPP
